package bartenderqueue;

import java.io.*;
import java.util.logging.Level;
import java.util.logging.Logger;


/**
 * This class loads from the settings file
 * @author Charles Ritcheaa 
 */
public class Settings{
	/** */
	private static FileOutputStream fOut;
	/** */
	private static FileInputStream fIn;
	/** */
    private static DataInputStream dIn;
    private static BufferedReader br;
    private static InputStreamReader iSR;
    private static String bartenderServerPort;
    private static String bartenderClientPort;
    private static String kioskHostname;

    /**
     * 
     * @return
     */
    public static String getBartenderClientPort() {
        return bartenderClientPort;
    }

    /**
     * 
     * @return
     */
    public static String getBartenderServerPort() {
        return bartenderServerPort;
    }

    /**
     * 
     * @return
     */
    public static String getKioskHostname() {
        return kioskHostname;
    }

	/**
	 * 
	 */
	public static void loadSettings(){
		try {
			fIn = new FileInputStream("bartenderqueue.ini");
                        dIn = new DataInputStream(fIn);
                        iSR = new InputStreamReader(dIn);
                        br = new BufferedReader(iSR);
                        String strLine;
                        for(int i = 0; (strLine = br.readLine()) != null; i++){
                            switch(i){
                                case 1:
                                    bartenderServerPort = strLine;
                                    System.out.println(bartenderServerPort);
                                    break;
                                case 3:
                                    bartenderClientPort = strLine;
                                    System.out.println(bartenderClientPort);
                                    break;
                                case 5:
                                    kioskHostname = strLine;
                                    System.out.println(kioskHostname);
                                    break;
                            }
                        }
			iSR.close();
		} catch (IOException ex) {
			Logger.getLogger(Settings.class.getName()).log(Level.SEVERE, null, ex);
		} 
	}
}